/*
 * @Descripttion: 
 * @TapdLink: https://XXX
 * @DesignsLink: https://XXX
 * @RelatedPersons: XXX[市场]、XXX[产品]、XXX[前端]、XXX[后端]、XXX[设计]
 * @version: 1.0.0
 * @Author: Shentong
 * @LastEditors: shentong
 * @Date: 2021-10-25 11:33:46
 */
import { NEWADDRESS, DELADDRESS, COUPONID, DEL_COUPONID, COUPONLIST } from '../constants/index'

interface IPayload {
  address: string;
  addressId: string;
  cellPhone: string | number;
  detailAdd: string,
  gender: string | number;
  userName: string;
  lat: string;
  lon: string;
  deliveryFloor: string | number;
}

interface IAction {
  payload: IPayload;
  type: string;
}

const INITIAL_STATE: IPayload  = {
  address: '',
  addressId: '',
  cellPhone: '',
  detailAdd: '',
  gender: 1,
  userName: '',
  lat: '',
  lon: '',
  deliveryFloor: ''
}

export default function curAddress (state = INITIAL_STATE, action: IAction ) {
  switch (action.type) {
    case NEWADDRESS:
      return {
        ...state,
        ...action.payload
      }
     case DELADDRESS:
       return {
         ...state
       }
     default:
       return state
  }
}

